﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace eHouse
{
    public class Rule
    {
        public string Id { get; set; }
        public string Time { get; set; }
        public object Data { get; set; }
        public string Formatted { get; set; }

        public override string ToString()
        {
            if (Data.GetType() == typeof(string))
            {
                return (string)Data + "ºC";
            }
            else if (Data.GetType() == typeof(bool))
            {
                return ((bool)Data ? "Turn ON" : "Turn OFF");
            }
            System.Collections.Generic.Dictionary<string, bool> dict = Data as System.Collections.Generic.Dictionary<string, bool>;
            string desc = "Turn " + (dict["VALUE"] ? "ON" : "OFF") + " these lights: ";
            foreach (System.Collections.Generic.KeyValuePair<string, bool> each in dict)
            {
                if (each.Key == "VALUE" || !each.Value)
                {
                    continue;
                }
                //desc += each.Key + "; " + (each.Value ? "YES; " : "NO; ");
                desc += each.Key + "; ";
            }
            return desc;
        }
    }
}
